package generalpattern.diagram.part;

import generalpattern.diagram.providers.GeneralPatternMetamodelElementTypes;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class GeneralPatternMetamodelPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createPatternElement1Group());
		paletteRoot.add(createPatternConnector2Group());
		paletteRoot.add(createComposingElement3Group());
		paletteRoot.add(createCCViewElement4Group());
		paletteRoot.add(createCCViewConnector5Group());
	}

	/**
	 * Creates "Pattern Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createPatternElement1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.PatternElement1Group_title);
		paletteContainer.setId("createPatternElement1Group"); //$NON-NLS-1$
		paletteContainer.add(createPattern1CreationTool());
		paletteContainer.add(createRole2CreationTool());
		paletteContainer.add(createConstraint3CreationTool());
		paletteContainer.add(createMultiplicity4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Pattern Connector" palette tool group
	 * @generated
	 */
	private PaletteContainer createPatternConnector2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.PatternConnector2Group_title);
		paletteContainer.setId("createPatternConnector2Group"); //$NON-NLS-1$
		paletteContainer.add(createElementtoRole1CreationTool());
		paletteContainer.add(createElementtoMultiplicity2CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Composing Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createComposingElement3Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.ComposingElement3Group_title);
		paletteContainer.setId("createComposingElement3Group"); //$NON-NLS-1$
		paletteContainer.add(createOverlapping1CreationTool());
		paletteContainer.add(createStringing2CreationTool());
		paletteContainer.add(createRelationtoSource3CreationTool());
		paletteContainer.add(createRelationtoTarget4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "C&C View Element" palette tool group
	 * @generated
	 */
	private PaletteContainer createCCViewElement4Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.CCViewElement4Group_title);
		paletteContainer.setId("createCCViewElement4Group"); //$NON-NLS-1$
		paletteContainer.add(createComponent1CreationTool());
		paletteContainer.add(createConnector2CreationTool());
		paletteContainer.add(createComponentPort3CreationTool());
		paletteContainer.add(createConnectorRole4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "C&C View Connector" palette tool group
	 * @generated
	 */
	private PaletteContainer createCCViewConnector5Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				Messages.CCViewConnector5Group_title);
		paletteContainer.setId("createCCViewConnector5Group"); //$NON-NLS-1$
		paletteContainer.add(createComponentPorttoConnectorRole1CreationTool());
		paletteContainer.add(createComponentPorttoComponentPort2CreationTool());
		paletteContainer.add(createConnectorRoletoConnectorRole3CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPattern1CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				3);
		types.add(GeneralPatternMetamodelElementTypes.Pattern_2022);
		types.add(GeneralPatternMetamodelElementTypes.Pattern_3030);
		types.add(GeneralPatternMetamodelElementTypes.Pattern_3032);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Pattern1CreationTool_title,
				Messages.Pattern1CreationTool_desc, types);
		entry.setId("createPattern1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Pattern_2022));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRole2CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralPatternMetamodelElementTypes.Role_3023);
		types.add(GeneralPatternMetamodelElementTypes.Role_2025);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Role2CreationTool_title,
				Messages.Role2CreationTool_desc, types);
		entry.setId("createRole2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Role_3023));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConstraint3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Constraint3CreationTool_title,
				Messages.Constraint3CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.Constraint_3024));
		entry.setId("createConstraint3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Constraint_3024));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createMultiplicity4CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralPatternMetamodelElementTypes.Multiplicity_3033);
		types.add(GeneralPatternMetamodelElementTypes.Multiplicity_2026);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Multiplicity4CreationTool_title, null, types);
		entry.setId("createMultiplicity4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Multiplicity_3033));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createElementtoRole1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ElementtoRole1CreationTool_title,
				Messages.ElementtoRole1CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ElementRoles_4016));
		entry.setId("createElementtoRole1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createElementtoMultiplicity2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ElementtoMultiplicity2CreationTool_title,
				Messages.ElementtoMultiplicity2CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ElementMultiplicity_4013));
		entry.setId("createElementtoMultiplicity2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createOverlapping1CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralPatternMetamodelElementTypes.Overlapping_3034);
		types.add(GeneralPatternMetamodelElementTypes.Overlapping_2027);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Overlapping1CreationTool_title,
				Messages.Overlapping1CreationTool_desc, types);
		entry.setId("createOverlapping1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Overlapping_3034));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createStringing2CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				2);
		types.add(GeneralPatternMetamodelElementTypes.Stringing_3035);
		types.add(GeneralPatternMetamodelElementTypes.Stringing_2028);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Stringing2CreationTool_title,
				Messages.Stringing2CreationTool_desc, types);
		entry.setId("createStringing2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Stringing_3035));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRelationtoSource3CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.RelationtoSource3CreationTool_title,
				Messages.RelationtoSource3CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.MergingOperatorSource_4017));
		entry.setId("createRelationtoSource3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRelationtoTarget4CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.RelationtoTarget4CreationTool_title,
				Messages.RelationtoTarget4CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.MergingOperatorTarget_4018));
		entry.setId("createRelationtoTarget4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponent1CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				3);
		types.add(GeneralPatternMetamodelElementTypes.Component_3025);
		types.add(GeneralPatternMetamodelElementTypes.Component_3027);
		types.add(GeneralPatternMetamodelElementTypes.Component_2023);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Component1CreationTool_title,
				Messages.Component1CreationTool_desc, types);
		entry.setId("createComponent1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Component_3025));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnector2CreationTool() {
		ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/types = new ArrayList/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/(
				3);
		types.add(GeneralPatternMetamodelElementTypes.Connector_3028);
		types.add(GeneralPatternMetamodelElementTypes.Connector_3031);
		types.add(GeneralPatternMetamodelElementTypes.Connector_2024);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Connector2CreationTool_title,
				Messages.Connector2CreationTool_desc, types);
		entry.setId("createConnector2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.Connector_3028));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentPort3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ComponentPort3CreationTool_title,
				Messages.ComponentPort3CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ComponentPort_3026));
		entry.setId("createComponentPort3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.ComponentPort_3026));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnectorRole4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.ConnectorRole4CreationTool_title,
				Messages.ConnectorRole4CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ConnectorRole_3029));
		entry.setId("createConnectorRole4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelElementTypes
				.getImageDescriptor(GeneralPatternMetamodelElementTypes.ConnectorRole_3029));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentPorttoConnectorRole1CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ComponentPorttoConnectorRole1CreationTool_title,
				Messages.ComponentPorttoConnectorRole1CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ComponentPortAttachedRole_4005));
		entry.setId("createComponentPorttoConnectorRole1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createComponentPorttoComponentPort2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ComponentPorttoComponentPort2CreationTool_title,
				Messages.ComponentPorttoComponentPort2CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ComponentPortDelegatedPorts_4020));
		entry.setId("createComponentPorttoComponentPort2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createConnectorRoletoConnectorRole3CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ConnectorRoletoConnectorRole3CreationTool_title,
				Messages.ConnectorRoletoConnectorRole3CreationTool_desc,
				Collections
						.singletonList(GeneralPatternMetamodelElementTypes.ConnectorRoleDelegatedRoles_4019));
		entry.setId("createConnectorRoletoConnectorRole3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		entry.setLargeIcon(GeneralPatternMetamodelDiagramEditorPlugin
				.findImageDescriptor("/org.admanager.generalpattern.plugin/icons/full/obj16/Relationship.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(
				String title,
				String description,
				List/*[org.eclipse.gmf.runtime.emf.type.core.IElementType]*/relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
